package com.shuma.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shuma.auth.mapper.ProductCategoryMapper;
import com.shuma.auth.model.po.ProductCategory;
import com.shuma.auth.service.ProductCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lele
 */
@Slf4j
@Service
public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMapper, ProductCategory> implements ProductCategoryService {

    @Resource
    ProductCategoryMapper productCategoryMapper;
    @Override
    public List<ProductCategory> listType() {

        LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ProductCategory::getParentId,"1");
        List<ProductCategory> productCategories = productCategoryMapper.selectList(queryWrapper);
        return productCategories;
    }

    @Override
    public List<ProductCategory> listCategory(String typeId) {
        LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ProductCategory::getParentId,typeId);
        List<ProductCategory> productCategories = productCategoryMapper.selectList(queryWrapper);
        return productCategories;
    }
}
